<?php

use yii\helpers\Html;
use yii\widgets\LinkPager;

/* @var $this yii\web\View */
/* @var $searchModel app\models\QaSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '问答';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="qa-index">

    <h3>今天，你在开发时遇到了什么问题呢？<a class="btn btn-success" href="/qa/create">我要提问</a> </h3>
    <table class="table">
        <ul id="myTab" class="nav nav-tabs" role="tablist">
            <li role="presentation" class=""><a href="/qa">最新的</a></li>
            <li role="presentation" class="active"><a href="/qa/hot" >最热门</a></li>
        </ul>
        <tbody>
            <?php foreach ($qa_list as $row): ?>
                <tr>
                    <td class="w50"><div class="<?php echo $row->comments ? 'answers' : 'no-answers' ?>"><?php echo $row->comments; ?><small>回答</small></div></td>
                    <td class="w50"><div class="views"><?php echo $row['view']; ?><small>浏览</small></div></td>
                    <td>
                        <span><?php echo $row->author->username ?> &nbsp;&nbsp;<?php echo Yii::$app->formatter->asRelativeTime($row->created_at) ?>&nbsp;发布</span><br>
                        <a href="/qa/view?id=<?php echo $row['id'] ?>"><?php echo $row['title']; ?></a>
                        <?php foreach ($row->tags($row['id']) as $item): ?>
                            <a class="btn btn-success btn-xs" href="/tags/show?id=<?php echo $item->id ?>" role="button"><?php echo $item->name ?></a>
                        <?php endforeach; ?>
                    </td>
                </tr>
            <?php endforeach; ?>

            <?php
            // 显示分页
            echo LinkPager::widget(['pagination' => $pages]);
            ?>
        </tbody>
    </table>

</div>
